package com.summer.main;

public class SingletonTest {

	
	public static void main(String[] args) {
		System.out.println("开始");
//		SingletonTest.num = 2;
//		System.out.println(SingletonTest.num);
		
		System.out.println(SingletonTest.defaultData(3).num);
		System.out.println(SingletonTest.defaultData(7).num);
	}
	
	
	
	public static Data defaultData(int num){
		DefaultConfig.num = num;
        return DefaultConfig.Builder.DATA;
    }

	public static class DefaultConfig{
		public static int num = 6;
	    public static class Builder {
	        public static final Data DATA = newData(num);
	        public static Data newData(int num) {
	        	System.out.println("newData");
	            return new Data(num);
	        }
	    }
	}
    
    
    public static class Data{
    	public final int num;
    	public Data(int num){
    		this.num = num;
    	}
    }
    
}
